<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<html>
<head>
<%@include file="/fragment/header.jsp"%>
<meta charset="utf-8">
<title>快速選擇任務</title>
<script language="javascript">
	function pickLov(wbsSn, wbsName) {
        $("#editWbsSn", window.opener.document).val(wbsSn);
        $("#editWbsName", window.opener.document).val(wbsName);
		window.close();
	}
    function changeAction(){
    	document.getElementById("wbsSelectForm").action='${pageContext.request.contextPath}/workLog/initQuickAddWbs.do';
        return true;
    }
</script>
<script>
	/*
	 $(document)
	 .ready(
	 function() {
	 $('#searchWbsName').autocomplete({
	 serviceUrl : '${pageContext.request.contextPath}/workLog/pickWbsTask.do',
	 //paramName : "wbsName", //default 'query'
	 delimiter : ",",
	 minChars: 2,
	 transformResult : function(response) {
	 return {
	 //must convert json to javascript object before process
	 suggestions : $.map($.parseJSON(response),function(item) {
	 return {
	 value : item.name,
	 data : item.sn
	 };
	 })
	 };
	 }
	 });
	 });
	 */
</script>
<script>
	/*
	 $(document)
	 .ready(
	 function() {
	 $('#searchWbsName').autocomplete({
	 //source : '${pageContext.request.contextPath}/workLog/pickWbsTask.do',
	 source: [ "選擇題", "多重選擇", "選擇一項", "冷兵器", "javascript", "asp", "ruby", "JavaScript", "VBScript" ],
	 minLength : 2, 
	 autoFocus: true
	 }).addClass("ac_input")
	                 .bind("dblclick", function () {
	                     $(this).autocomplete("search", this.value);
	                 })
	                 .bind("input.autocomplete", function () {
	                     // 修复在Firefox中不支持中文的BUG
	                     $(this).autocomplete("search", this.value);
	                 });
	 });
	 */
</script>
</head>


<body>
    <form:form commandName="wbsSelectForm"  id="wbsSelectForm" method="post" action="${pageContext.request.contextPath }/workLog/findWbs.do" autocomplete="off">
        <fieldset>
            <legend class="section_title">任務搜尋</legend>
            &nbsp;專案:
            <form:select path="projSn" id="projSn">
                <form:options items="${projs}" />
            </form:select>
            名稱
            <form:input path="wbsName" value="" size="10" />
            任務類型:
            <form:select path="wbsTypeId">
                <form:option value="">---</form:option>
                <form:options items="${wbsTypes }" />
            </form:select>
            <form:button type="submit" class="btn" value="searchWbs">搜尋</form:button>
        </fieldset>
        <form:button   class="btn" name="quickAdd" value="quickAdd"  onclick="return changeAction();">立刻新增</form:button>
        <div style="float: true; height: 280px">
            <table border="1">
                <tr>
                    <td>選取</td>
                    <td>類型</td>
                    <td>任務</td>
                </tr>
                <c:forEach items="${wbsDbvoList }" var="wbs">
                <tr>
                    <td><input type="radio" name="radio" id="radio" value="radio" onClick="pickLov('${wbs.sn}','${wbs.name }')"></td>
                    <td>${wbs.typeDscr}</td>
                    <td>${wbs.name}</td>
                </tr>
             
                </c:forEach>
            </table>
        </div>
    </form:form>

</body>
</html>
